using System.Globalization;

namespace MauiBuilder.Converters
{
    /// <summary>
    /// 布尔值到小时按钮样式的转换器
    /// </summary>
    public class BoolToHourButtonStyleConverter : IValueConverter
    {
        public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
        {
            if (value is bool isSelected)
            {
                if (Application.Current?.Resources != null)
                {
                    var styleName = isSelected ? "PrimaryButtonStyle" : "SecondaryButtonStyle";
                    if (Application.Current.Resources.TryGetValue(styleName, out var style))
                    {
                        return style;
                    }
                }
            }
            
            // 返回默认样式
            return Application.Current?.Resources?["SecondaryButtonStyle"];
        }

        public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}